﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess.DataObject;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;

namespace DataAccess.BusinessObject
{
    public class BSurvey:Common.CDBase
    {
        public bool Add(OSurvey _OSurvey)
        {
            SqlParameter[] sqlParam = { new SqlParameter("@GuestName",SqlDbType.NVarChar),
                                        new SqlParameter("@Age",SqlDbType.NVarChar),
                                        new SqlParameter("@Job",SqlDbType.NVarChar),
                                        new SqlParameter("@Address",SqlDbType.NVarChar),
                                        new SqlParameter("@EstateType",SqlDbType.NVarChar),
                                        new SqlParameter("@Area",SqlDbType.NVarChar),
                                        new SqlParameter("@Price",SqlDbType.NVarChar),
                                        new SqlParameter("@Direction",SqlDbType.NVarChar),
                                        new SqlParameter("@FutaLand",SqlDbType.NVarChar),
                                        new SqlParameter("@Region",SqlDbType.NVarChar),
                                        new SqlParameter("@Why",SqlDbType.NVarChar),};
            sqlParam[0].Value = _OSurvey.GuestName;
            sqlParam[1].Value = _OSurvey.Age;
            sqlParam[2].Value = _OSurvey.Job;
            sqlParam[3].Value = _OSurvey.Address;
            sqlParam[4].Value = _OSurvey.EstateType;
            sqlParam[5].Value = _OSurvey.Area;
            sqlParam[6].Value = _OSurvey.Price;
            sqlParam[7].Value = _OSurvey.Direction;
            sqlParam[8].Value = _OSurvey.FutaLand;
            sqlParam[9].Value = _OSurvey.Region;
            sqlParam[10].Value = _OSurvey.Why;
            return RunProcedure("sp_tblSurvey_add", sqlParam);
        }
        public IList<OSurvey> Get(int PageIndex,int PageSize)
        {
            SqlParameter[] sqlParam = { new SqlParameter("@PageIndex",SqlDbType.Int),
                                        new SqlParameter("@PageSize",SqlDbType.Int)};
            sqlParam[0].Value = PageIndex;
            sqlParam[1].Value = PageSize;
            return Common.Common.ConvertTo<OSurvey>(RunProcedureGet("sp_tblSurvey_get", sqlParam));
        }
        public IList<OSurvey> Get(DateTime FromDate,DateTime ToDate,int PageIndex, int PageSize)
        {
            SqlParameter[] sqlParam = { new SqlParameter("@FromDate", SqlDbType.DateTime),
                                        new SqlParameter("@ToDate", SqlDbType.DateTime),
                                        new SqlParameter("@PageIndex", SqlDbType.Int),
                                        new SqlParameter("@PageSize", SqlDbType.Int) };
            sqlParam[0].Value = FromDate;
            sqlParam[1].Value = ToDate;
            sqlParam[2].Value = PageIndex;
            sqlParam[3].Value = PageSize;
            return Common.Common.ConvertTo<OSurvey>(RunProcedureGet("sp_tblSurvey_get", sqlParam));
        }
    }
}
